package com.example.gokuplayalong.service.fragments.others;

import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.donkingliang.labels.LabelsView;
import com.example.gokuplayalong.R;
import com.example.gokuplayalong.bases.beans.Beans;
import com.example.gokuplayalong.bases.custom.UserBaseViewHolder;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

public class UserMainPageAdapter extends RecyclerView.Adapter<UserBaseViewHolder> {

    public final static int VIEWTYPE_SIGNAL = 1;
    public final static int VIEWTYPE_MESSAGE_CHAT = 2;
    public final static int VIEWTYPE_RECEIVE_LIST = 3;
    public final static int VIEWTYPE_CHAT_LIST = 4;
    public final static int VIEWTYPE_ORDER_LIST = 5;


    List<Beans> beans = new ArrayList<>();



    public UserMainPageAdapter(List<Beans> beans) {
        this.beans = beans;
    }

    @NonNull
    @Override
    public UserBaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        switch (viewType) {
            case VIEWTYPE_MESSAGE_CHAT:
                return new UserMainPageChatPageViewHolder(LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.fragment_user_main_message_chat_page_item, parent, false));
            case VIEWTYPE_RECEIVE_LIST:
                return new UserMainPageReceiveViewHolder(LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.fragment_user_main_receive_item, parent, false));
            case VIEWTYPE_CHAT_LIST:
                return new UserMainMessageChatListViewHolder(LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.fragment_user_main_receive_item, parent, false));
            case VIEWTYPE_ORDER_LIST:
                return new UserMainPageOrderListListViewHolder(LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.fragment_user_main_profile_my_order_item, parent, false));

            default:
                return new UserMainPageViewHolder(LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.fragment_user_main_message, parent, false));
        }
    }

    @Override
    public void onBindViewHolder(@NonNull UserBaseViewHolder holder, int position) {
        holder.bindView(beans, beans.get(position));
    }

    @Override
    public int getItemCount() {
        return beans == null ? 0 : beans.size();
    }

    @Override
    public int getItemViewType(int position) {
        return StringUtils.isEmpty("" + beans.get(position)
                .getJsonObject()
                .getIntValue("viewType")) ? 0 : beans.get(position)
                .getJsonObject()
                .getIntValue("viewType");
    }


    private void initView() {

    }
}